exports.install = (Vue, options) => {

/*
 * 请求数据
 *
 * */

    /* 医生列表 */
    Vue.prototype.getDoctorData = ()=> {
        let tokenId =  sessionStorage.getItem("tokenId");
        Vue.prototype.$http({
            url: '/api/adscm/application/bodyCheck/queryDoctor?tokenId='+tokenId+'&id=4',
            method: 'post',
            headers: {'X-Requested-With': 'XMLHttpRequest'},
        }).then(function (res) {

            console.log( res.data )

            if (res.data.statusCode == 200) {
                Vue.prototype.dictorData =  res.data.content;
            } else {
                Vue.prototype.$message.error(res.data.desc);
            }
        }).catch(function (catchres) {
             Vue.prototype.$message.error("加载失败！请重新加载...");
        });
    };

    /* 护士列表 */
    Vue.prototype.getNurseData = ()=> {
        Vue.prototype.$http({
            url: '/api/adscm/system/user/queryUsersByRoleId/5',
            method: 'post',
            headers: {'X-Requested-With': 'XMLHttpRequest'},
        }).then(function (res) {
            console.log( res.data )

            if (res.data.statusCode == 200) {
                Vue.prototype.nurseData =  res.data.content;
            } else {
                Vue.prototype.$message.error(res.data.desc);
            }
        }).catch(function (catchres) {
            Vue.prototype.$message.error("加载失败！请重新加载...");
        });
    };


    /* 分配机列表 */
    Vue.prototype.getMachineCodeData = ()=> {
        Vue.prototype.$http({
            url: '/api/adscm/application/jzMachine/selectUseingMachine',
            method: 'post',
            headers: {'X-Requested-With': 'XMLHttpRequest'},
        }).then(function (res) {
            if (res.data.statusCode == 200) {
                Vue.prototype.machineCodeData =  res.data.content;
            } else {
                Vue.prototype.$message.error(res.data.desc);
            }
        }).catch(function (catchres) {
            Vue.prototype.$message.error("加载失败！请重新加载...");
        });
    };


    /* 码表列表 */
    Vue.prototype.getCodeData = (id)=> {
        Vue.prototype.$http({
            url: '/api/adscm/system/code/selectByCodeType/' + id,
            method: 'post',
            headers: {'X-Requested-With': 'XMLHttpRequest'},
        }).then(function (res) {
            if (res.data.statusCode == 200) {
                Vue.prototype['codeData' + id] =  res.data.content;
            } else {
                Vue.prototype.$message.error(res.data.desc);
            }
        }).catch(function (catchres) {
            Vue.prototype.$message.error("加载失败！请重新加载...");
        });
    };

    /* 机器编号列表 */
    Vue.prototype.getMachineData = ()=> {
        Vue.prototype.$http({
            url: '/api/adscm/application/jzMachine/selectUseingMachine',
            method: 'post',
            headers: {'X-Requested-With': 'XMLHttpRequest'},
        }).then(function (res) {
            if (res.data.statusCode == 200) {
                Vue.prototype.machineData =  res.data.content;
            } else {
                Vue.prototype.$message.error(res.data.desc);
            }
        }).catch(function (catchres) {
            Vue.prototype.$message.error("加载失败！请重新加载...");
        });
    };



    /* 时间戳转时间格式*/
    Vue.prototype.timestampToTime = (timestamp)=> {
        if (timestamp) {
            let date = new Date(timestamp);
            let Y = date.getFullYear() + '-';
            let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
            let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
            let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
            return timestamp ? Y + M + D + h + m + '00' : '';
        } else {
            return '';
        }
    };


    /*
    * table
    * 表格统一样式
    * */

    /* 表格的样式隔行颜色 */
    Vue.prototype.getRowClass = ({row, column, rowIndex, columnIndex})=> {
        if (rowIndex == 0) {
            return 'background:#EFEFEF;color:#000;box-shadow: 2px 0px 0px 2px #999;'
        } else {
            return ''
        }
    };


    /* 表格中男女 */
    Vue.prototype.formatSex =  (row, column, cellValue, index)=> {
        return cellValue == 1 ? '男' : (cellValue == 2 ? '女' : '');
    };

    /* 表格中认证方式  */
    Vue.prototype.formatterAuthMethod = (row, column, cellValue, index)=> {
        return cellValue == 0 ? '人工认证' : (cellValue == 1 ? '人脸识别' : (cellValue == 2 ? '指纹认证' : ""));
    };

    /* 表格中体检结果  */
    Vue.prototype.formatterBodyCheckResult = (row, column, cellValue, index)=> {
        return cellValue == 0 ? '合格' : (cellValue == 1 ? '不合格' : "");
    };

    /* 表格中记录状态  */
    Vue.prototype.formatterRecodeStatus = (row, column, cellValue, index)=> {
        return cellValue == 0 ? '已处理' : (cellValue == 1 ? '待处理' : "");
    };

    /* 表格中记录状态  */
    Vue.prototype.formatterIsRecode = (row, column, cellValue, index)=> {
        return cellValue == 1 ? '已处理' : (cellValue == 0 ? '待处理' : "");
    };


    /* 表格中是或者否  */
    Vue.prototype.formatterIsTrain = (row, column, cellValue, index)=> {
        return cellValue == 1 ? '合格' : (cellValue == 0 ? '不合格' : "");
    };






    /*
    * editor
    * 富文本
    * */
    Vue.prototype.onEditorFocus = (event)=> {
        event.enable(false);
    };

    /*
    * page
    * 分页
    * */
    Vue.prototype.handleSizeChange = (size)=> {
        this.pagesize = size;
    };
    Vue.prototype.handleCurrentChange = (currentPage)=> {
        this.currentPage = currentPage;
    };

    /*
    * 打印
    * */
    Vue.prototype.PrintData = ()=> {
        let printHtml = document.getElementById("printData").innerHTML;
        let wind = window.open("", 'newwindow', 'height=2000, width=2000, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');
        wind.document.body.innerHTML = printHtml;
        wind.print();
        wind.window.document.body.innerHTML = '';
    };


};

